package com.teach.food.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.teach.dto.CommentsSearch;
import com.teach.dto.LoginUser;
import com.teach.entity.News;
import com.teach.food.commons.GetShopsInfo;
import com.teach.food.service.CommentsService;
import com.teach.food.service.FoodMerchantService;

import lombok.extern.slf4j.Slf4j;

/**
 * <pre>
 * 评论控制器
 * Author : G_peng
 * Date : 2019年12月17日
 * Version : 0.0.1
 * Copyright 2019 Gpeng.top Inc. All rights reserved. 
 * </pre>
 */
@Controller
@RequestMapping("/food/comments")
@Slf4j
public class CommentsController {
	@Autowired
	private CommentsService service;
	@Autowired
	private CommentsSearch	search;
	@Autowired
	private GetShopsInfo info;
	
	@RequestMapping("page-{i}.html")
	public String doPage(Model model,LoginUser user,@PathVariable Integer i,@RequestParam(value = "username",defaultValue = "")String username) {
		search.setCommentCommentator(info.getShopId(user));
		search.setCommentUserName(username);
		search.setCurrent(i);
		log.debug("{}","666:"+service.pageSearch(search));
		model.addAttribute("p",service.pageSearch(search));
		return "/food/evaluate";
	}
}
